#pragma once

#include <sys/epoll.h>

#include "conn.h"

using namespace std;

class socket_worker
{
private:
    // epoll description file
    int epollfd;

public:
    void init();
    void operator()();

public:
    // socket event curd
    void add_event(int fd);
    void remove_event(int fd);
    void modify_event(int fd, bool epollout);

    // 网络事件, 有新连接|连接可读可写
    void onevent(struct epoll_event ev);
    void onaccept(shared_ptr<conn> conninst);
    void onrw(shared_ptr<conn> conninst, bool r, bool w); // on read write
};